
let nums = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4]
// 输出：5, nums = [0,1,2,3,4]

var removeDuplicates = function (nums) {
  let i = 0, j = 1, k = 0
  let res = []
  while (j < nums.length) {
    if (nums[i] === nums[j]) {
      j++
    } else {
      res[k++] = nums[i]
      i = j
      j++
    }
  }
  res[k] = nums[i]
  console.log(res);
};

removeDuplicates(nums)


